export function createAnimate(options) {
    let from = options.from;
    let to = options.to;
    let totalMS = options.totalMS || 1000;
    let duration = options.duration || 15;  // 每多少时间变化一次
    let times = Math.floor(totalMS / duration);  // 变化的总次数
    let dis = (to - from) / times // 每一次变化改变的值
    let curTimes = 0;  // 当前变化的次数
    let timerId = setInterval(function () {
        from += dis;
        curTimes++;
        if (curTimes >= times) {
            // 变化的次数达到了
            from = to; // 变化完成了
            
            clearInterval(timerId);
            options.onEnd && options.onEnd();
        }
        options.onMove && options.onMove(from)
    }, duration)

}